/**
  * @(#)SectionMeeting.java
  *
  * Meeting time location, day, and time
  *
  * @author Course Scheduler Team
  * 
  * @license GNU General Public License version 3 (GPLv3)
  *
  * This file is part of Course Scheduler, an open source, cross platform
  * course scheduling tool, configurable for most universities.
  *
  * Copyright (C) 2010-2012 Course Scheduler Team
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * 
  */
package com.pollicitus.scheduler.model;

import com.pollicitus.scheduler.model.MeetingTime;
import com.pollicitus.scheduler.model.SectionMeeting;
import com.pollicitus.scheduler.model.WeekDay;

/**
 * Represent the meeting time and place for a section
 * 
 * @author Course Scheduler Team
 *
 */
public class SectionMeeting {

	/**
	 * The most recent revision in which this file was changed in the source control system
	 */
	public static final String _revision = "$LastChangedRevision: 539 $";
	
	/**
	 * The date on which this file was last changed and submitted to source control
	 */
	public static final String _date = "$LastChangedDate: 2011-11-19 23:14:16 -0500 (Sat, 19 Nov 2011) $";
	
	/**
	 * The user which last changed the file and committed the change to source control
	 */
	public static final String _author = "$LastChangedBy: mike@pollicitus.com $";
	
	/**
	 * The URL which can be used to access this specific file within the source control system
	 */
	public static final String _headURL = "$HeadURL: https://courseschedulerx.googlecode.com/svn/trunk/course-scheduler/course-scheduler-core/src/main/java/com/pollicitus/scheduler/model/SectionMeeting.java $";
	
	/**
	 * The source control file ID, comprised of the file name, latest revision, last changed date, and submitting user.
	 */
	public static final String _id = "$Id: SectionMeeting.java 539 2011-11-20 04:14:16Z mike@pollicitus.com $";
		
	/**
	 * campus = physical campus of the section meeting
	 * building = physical building of the section meeting
	 * room = physical room of the section meeting
	 * day = WeekDay when the section meets
	 * time = time of the WeekDay the secton meets
	 */
	private String campus;
	private String building;
	private String room;
	private WeekDay day;
	private MeetingTime time;
	
	/**
	 * Create a new section meeting time and day instance
	 * 
	 * @param campus = university campus
	 * @param building = physical building
	 * @param room = room in the building
	 * @param day = WeekDay of the section
	 * @param time = time of the day
	 */
	public SectionMeeting(String campus, String building, String room, WeekDay day, MeetingTime time){
		super();
		
		this.campus=campus;
		this.building = building;
		this.room = room;
		this.day = day;
		this.time = time;
	}
	
	/**
	 * Return the room in which the section will meet
	 * 
	 * @return room the section meeting room
	 */
	public String getRoom() {
		return room;
	}
	
	/**
	 * Set the room in which the section will meet
	 * 
	 * @param room the section meeting room
	 */
	public void setRoom(String room) {
		this.room = room;
	}
	
	/**
	 * Return the day of the week the section meets
	 * 
	 * @return meeting day of the week
	 */
	public WeekDay getDay() {
		return day;
	}
	
	/**
	 * Set the meeting day of the week
	 * 
	 * @param day the day the section meets
	 */
	public void setDay(WeekDay day) {
		this.day = day;
	}
	
	/**
	 * Return the time component of the section meeting
	 * 
	 * @return time component of the meeting
	 */
	public MeetingTime getTime() {
		return time;
	}
	
	/**
	 * Set the time component of the section meeting
	 * 
	 * @param time time when the section meets
	 */
	public void setTime(MeetingTime time) {
		this.time = time;
	}

	/**
	 * Return which campus the section meets at (for universities which have
	 * multiple locations)
	 * 
	 * @return the campus the section meeting takes place at
	 */
	public String getCampus() {
		return campus;
	}

	/**
	 * Set the meeting location's campus
	 * 
	 * @param campus where the meeting takes place
	 */
	public void setCampus(String campus) {
		this.campus = campus;
	}

	/**
	 * Return the building on the campus where the section will meet
	 * 
	 * @return the building where the section meets
	 */
	public String getBuilding() {
		return building;
	}

	/**
	 * Set the building where the section meets
	 * 
	 * @param building where the section meets
	 */
	public void setBuilding(String building) {
		this.building = building;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object o){
		SectionMeeting other = (SectionMeeting)o;
		
		return other.getBuilding().compareTo(this.getBuilding()) == 0 &&
				other.getCampus().compareTo(this.getCampus()) == 0 &&
				other.getRoom().compareTo(this.getRoom()) == 0 &&
				other.getDay().equals(this.getDay()) &&
				other.getTime().equals(this.getTime());
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode(){
		return this.getBuilding().hashCode() ^
				this.getCampus().hashCode() ^
				this.getDay().hashCode() ^ 
				this.getRoom().hashCode() ^ 
				this.getTime().hashCode();
	}
}
